const {seq, DataTypes} = require('../sequelize')

const UserAttributes = {
    username: {
        type: DataTypes.STRING,
        allowNull: false,
        unique: 'user_username' // 创建唯一索引
    },
    password: {
        type: DataTypes.STRING,
        allowNull: false,
    },
    avatar: {
        type: DataTypes.TEXT,
        Comment: '头像'
    },
    phone: {
        type: DataTypes.STRING,
        unique: true,
        Comment: '手机号' 
    },
    email: {
        type: DataTypes.STRING
    }
}

const User = seq.define('yyb_user', UserAttributes, {
    createdAt: true,
    updatedAt: true,
    timestamps: false,
    freezeTableName: true
})

User.sync() 

module.exports = {
    User,
    UserAttributes
} 
